<?php
spl_autoload_register(function($class_name){
    include "$class_name.class.php";
});
    //配置
    define('ROOT', 'http://'.$_SERVER['HTTP_HOST']);

    // css目录
    define('CSS_DIR', ROOT.'/static/styles/');

    // js目录
    define('JS_DIR', ROOT.'/static/scripts/');

    // 图片路径
    define('IMG_DIR', ROOT.'/static/images/');

    // views路径
    define('VIEWS_DIR', ROOT.'/views/');
    
    session_start();

    include 'functions.php';

    // 数据库连接
    $config = [
        'host' => 'localhost',
        'user' => 'root',
        'pwd' => 123456,
        'dbname' => 'nndou',
        'prefix' => 'nnd_',
        'charset' => 'uft8'
    ];

    $db = MySqlDb::getInstance($config);

    $user_info = ['link' => $db];
    $login = Login::getInstance($user_info);

    //分页参数
    $limit = 6;      //每页显示六条
    $size = 5;       //每页显示五页
    $current = (!empty($_GET['page'])) ? $_GET['page'] : 1;  //获取当前页面,默认第一页
    $offset = ($current - 1) * $limit;      //偏移量
